package com.chuangmi.decoder;

import java.nio.ByteBuffer;

/**
 * Created by sunhongda on 2017/6/16.
 */
public class ImiVideoDecoder {
    public static final int TYPE_H265 = 102;
    public static final int TYPE_H264 = 101;

    private static native int nativeInit(int[] mHandle);

    public ImiVideoDecoder() {
//        nativeInit();
    }

    public native void selectDecoder(int[] mHandle, int videoType, int flag);

    public native void release(int[] mHandle);

    public native boolean decode(int[] mHandle, byte[] data, int numBytes, long packetPTS);

    public native int getWidth(int[] mHandle);

    public native int getHeight(int[] mHandle);

    public native int toTexture(int[] mHandle, int textureYIndex, int textureUIndex, int textureVIndex);

    public native int getYuvData(int[] mHandle, ByteBuffer textureY, ByteBuffer textureU, ByteBuffer textureV);

    public native int getJpegBuffer(ByteBuffer textureY, ByteBuffer textureU, ByteBuffer textureV, ByteBuffer dst, int width, int height, int quality);

    public native int yuv420p2yuv420sp(byte[] yuv420p, byte[] yuv420sp, int width, int height);

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
//          release();
    }

}
